import React from 'react';
import { Card, Descriptions } from 'antd';
import { getDicByKey } from '@/support/common';
import PropTypes from 'prop-types';
export default class AlarmDataTab extends React.Component<any, any> {
  static contextTypes = {
    dicData: PropTypes.any,
  };
  render() {
    const { alarmVo2 } = this.props;
    let alarmVo = alarmVo2 || {};
    let { alarmCodeInfo } = alarmVo;
    alarmCodeInfo ? (alarmCodeInfo = alarmCodeInfo) : (alarmCodeInfo = {});

    const judge = target => {
      if (target === '1') {
        return '是';
      } else if (target === '0') {
        return '否';
      } else {
        return '';
      }
    };
    return (
      <>
        <Descriptions bordered size="small">
          <Descriptions.Item label="最高报警等级" span={3}>
            {alarmVo.maxAlarmLevel
              ? getDicByKey(this.context.dicData, 'maxAlarmLevel', `${alarmVo.maxAlarmLevel}`)
              : ''}
          </Descriptions.Item>
          <Descriptions.Item label="可充电储能装置故障总数 N1" span={1}>
            {alarmVo.energyStorageFaultTotal}
          </Descriptions.Item>
          <Descriptions.Item label="可充电储能装置故障代码列表" span={2}>
            {alarmVo.energyStorageFaultCodeList ? `${alarmVo.energyStorageFaultCodeList}` : ''}
          </Descriptions.Item>
          <Descriptions.Item label="驱动电机故障总数 N2" span={1}>
            {alarmVo.motorFaultTotal}
          </Descriptions.Item>
          <Descriptions.Item label="驱动电机故障代码列表" span={2}>
            {alarmVo.motorFaultCodeList ? `${alarmVo.motorFaultCodeList}` : ''}
          </Descriptions.Item>
          <Descriptions.Item label="发动机故障总数 N3" span={1}>
            {alarmVo.engineFaultTotal}
          </Descriptions.Item>
          <Descriptions.Item label="发动机故障列表" span={2}>
            {alarmVo.engineFaultCodeList ? `${alarmVo.engineFaultCodeList}` : ''}
          </Descriptions.Item>
          <Descriptions.Item label="其他故障总数 N4" span={1}>
            {alarmVo.otherFaultTotal}
          </Descriptions.Item>
          <Descriptions.Item label="其他故障代码列表" span={2}>
            {alarmVo.otherFaultCodeList ? `${alarmVo.otherFaultCodeList}` : ''}
          </Descriptions.Item>
        </Descriptions>
        <Card title="通用报警标识" bordered={false} style={{ padding: 0 }}>
          <Descriptions bordered size="small" style={{ padding: 0 }}>
            <Descriptions.Item label="温度差异报警">
              {judge(alarmCodeInfo.temperatureDiff)}
            </Descriptions.Item>
            <Descriptions.Item label="电池高温报警">
              {judge(alarmCodeInfo.batteryHighTemperature)}
            </Descriptions.Item>
            <Descriptions.Item label="车载储能装置类型过压报警">
              {judge(alarmCodeInfo.energyStorageDeviceOvervoltage)}
            </Descriptions.Item>
            <Descriptions.Item label="车载储能装置类型欠压报警">
              {judge(alarmCodeInfo.energyStorageDeviceUndervoltage)}
            </Descriptions.Item>
            <Descriptions.Item label="SOC低报警">{judge(alarmCodeInfo.socLower)}</Descriptions.Item>
            <Descriptions.Item label="单体电池过压报警">
              {judge(alarmCodeInfo.singleCellOvervoltage)}
            </Descriptions.Item>
            <Descriptions.Item label="单体电池欠压报警">
              {judge(alarmCodeInfo.singleCellUndervoltage)}
            </Descriptions.Item>
            <Descriptions.Item label="SOC过高报警">
              {judge(alarmCodeInfo.socOver)}
            </Descriptions.Item>
            <Descriptions.Item label="SOC跳变报警">
              {judge(alarmCodeInfo.socJumping)}
            </Descriptions.Item>
            <Descriptions.Item label="可充电储能系统不匹配报警">
              {judge(alarmCodeInfo.rechargeableRnergyStorageSystemMismatch)}
            </Descriptions.Item>
            <Descriptions.Item label="电池单体一致性差报警">
              {judge(alarmCodeInfo.batteryCellsConsistencyLow)}
            </Descriptions.Item>
            <Descriptions.Item label="绝缘报警">
              {judge(alarmCodeInfo.insulation)}
            </Descriptions.Item>
          </Descriptions>
        </Card>
      </>
    );
  }
}
